﻿using AutoMapper;
using crip.Dtos;
using crip.Helper;
using crip.Models;

namespace crip.Profiles
{
    public class UserProfile:Profile
    {
        public UserProfile()
        {
            CreateMap<CripUser, UserSimplifyDto>();
            CreateMap<CripUser, UserDto>()
                .ForMember(
                dest => dest.IsRealName,
                opt => opt.MapFrom(src => src.IsRealName ? "已实名" : "尚未实名")
                )
                .ForMember(
                dest => dest.frontIDCardUrl,
                opt => opt.MapFrom(
                    src => RSAHelper.RSADecrypt(src.frontIDCardUrl, src.Id))
                )
                .ForMember(
                         dest => dest.backIDCardUrl,
                opt => opt.MapFrom(
                    src => RSAHelper.RSADecrypt(src.backIDCardUrl, src.Id))
                )
                .ForMember(
                         dest => dest.RealID,
                opt => opt.MapFrom(
                    src => RSAHelper.RSADecrypt(src.RealID, src.Id))
                )
                .ForMember(
                         dest => dest.RealName,
                opt => opt.MapFrom(
                    src => RSAHelper.RSADecrypt(src.RealName, src.Id))
                );
        }
    }
}
